// 引入工具类
import { Util } from "../utils/util.js"
// 引入请求封装类
import { Http } from "../utils/http.js"
// 引入请求地址
import { serverUrl } from '../api/server_url.js'
// 引入md5加密
import md5 from 'js-md5'

class Request {
	static async FILEDOWNLOAD(fileUrl) { // 文件下载
		return await Http.request(serverUrl.FILEDOWNLOAD, {
			fileUrl
		}, 'POST', 'application/json', 'arraybuffer')
	}
	
	static async FILEUPLOAD(filePath, formData, name='') { // 文件上传
		return await Http.uploadFile(serverUrl.FILEUPLOAD, filePath, formData, name)
	}
	
	static async Login(userName, pwd) { // 登录
		// 验证是否为空
		if (Util.isNull(userName)) {
			Util.showToast('请输入内容')
			return
		}
		// 验证手机号
		// if (!Util.validPhone(userName)) {
		// 	return
		// }
		if (Util.isNull(pwd)) {
			Util.showToast('密码不能为空')
			return
		}
		// 验证密码
		// if (!Util.validPassword(pwd)) {
		// 	return
		// }
		let password = md5(pwd)
		return await Http.request(serverUrl.LOGIN, {
			userName,
			password
		}, 'POST', 'application/json')
	}
	
	static async USERALLADMIN(current, size, realName='', userName='') { // 用户管理查询
		return await Http.request(serverUrl.USERALLADMIN, {
			current, 
			size,
			realName,
			userName
		}, 'GET')
	}
	
	static async USERSYSADD(userName, password, phone, email, realName) { // 用户管理 添加
		// password = md5(password)
		return await Http.request(serverUrl.USERSYSADD, {
			userName, 
			password, 
			phone, 
			email, 
			realName
		}, 'POST', 'application/json')
	}
	
	static async QRCODEFINDALL(current, size, qrName='') { // 二维码分页查询
		return await Http.request(serverUrl.QRCODEFINDALL, {
			current, 
			size,
			qrName
		}, 'GET')
	}
	
	static async QRCODEADDQRCODE(qrCodeLink, qrName) { // 新增二维码
		return await Http.request(serverUrl.QRCODEADDQRCODE, {
			qrCodeLink, 
			qrName
		}, 'POST', 'application/json')
	}
	
	static async USERDELETE(id) { // 用户删除
		return await Http.request(serverUrl.USERDELETE + `/${id}`, {}, 'DELETE')
	}
	
	static async LINKFINDALL(current, size, channel, h5Name) { // 活动配置分页查询
		return await Http.request(serverUrl.LINKFINDALL, {
			current,
			size,
			channel, 
			h5Name
		}, 'GET')
	}
	
	static async LINKUPDATE(id, h5Status) { // 活动配置修改状态
		return await Http.request(serverUrl.LINKUPDATE + `/${id}`, {
			h5Status
		}, 'PUT', 'application/x-www-form-urlencoded')
	}
	
	static async LINKADDH5(h5Name, h5Link, channel, h5Status) { // 活动配置新增链接
		return await Http.request(serverUrl.LINKADDH5, {
			h5Name, 
			h5Link, 
			channel, 
			h5Status
		}, 'POST', 'application/json')
	}
	
	static async LINKDEL(id) { // 活动配置删除
		return await Http.request(serverUrl.LINKDEL + `/${id}`, {}, 'DELETE', 'application/x-www-form-urlencoded')
	}
	
	static async THIRDFINDALL(current, size, channel, tpName) { // 广告链接查询
		return await Http.request(serverUrl.THIRDFINDALL, {
			current, 
			size, 
			channel, 
			tpName
		}, 'GET')
	}
	
	static async THIRDADDPARTY(tpName, link, channel, tpStatus) { // 广告链接 添加
		return await Http.request(serverUrl.THIRDFINDALL, {
			tpStatus, 
			link, 
			channel, 
			tpName
		}, 'POST', 'application/x-www-form-urlencoded')
	}
	
	static async THIRDUPDATE(id, link) { // 广告链接 修改链接
		return await Http.request(serverUrl.THIRDUPDATE + `/${id}`, {
			link
		}, 'PUT', 'application/x-www-form-urlencoded')
	}
	
	static async THIRDUPDATESTATUS(id, tpStatus) { // 广告链接 修改链接状态
		return await Http.request(serverUrl.THIRDUPDATESTATUS + `/${id}`, {
			tpStatus
		}, 'PUT', 'application/x-www-form-urlencoded')
	}
	
	static async COUNTFINDALL(current, size, linkId) { // 分页获取UV-PV统计
		return await Http.request(serverUrl.COUNTFINDALL, {
			current, 
			size, 
			linkId
		}, 'GET')
	}
	
	static async CONTRACTFIND(current, size, companyName, contractStatus) { // 合同审核分页查询
		return await Http.request(serverUrl.CONTRACTFIND, {
			current, 
			size, 
			companyName, 
			contractStatus
		}, 'GET')
	}
	
	static async CERTIFICATIONFIND(current, size, companyName, certificationStatus) { // 财务认证分页查询
		return await Http.request(serverUrl.CERTIFICATIONFIND, {
			current, 
			size, 
			companyName, 
			certificationStatus
		}, 'GET')
	}
	
	static async MEDIAFINDALVERIFYL(current, size, mediaName, mediaStatus) { // 媒体审核分页查询
		return await Http.request(serverUrl.MEDIAFINDALVERIFYL, {
			current, 
			size, 
			mediaName, 
			mediaStatus
		}, 'GET')
	}
	
	
	static async THIRDFINDALLVERIFY(current, size, tpName, auditStatus) { // 媒体审核分页查询
		return await Http.request(serverUrl.THIRDFINDALLVERIFY, {
			current, 
			size, 
			tpName, 
			auditStatus
		}, 'GET')
	}
	
	static async MEDIAADD({ mcAdvertising, mcMal, mcToa, mediaIntro, mediaKeyword, mediaName, websiteName }) { // 媒体审核新增媒体
		return await Http.request(serverUrl.MEDIAADD, {
			mcAdvertising, 
			mcMal, 
			mcToa, 
			mediaIntro, 
			mediaKeyword, 
			mediaName, 
			websiteName
		}, 'POST', 'application/json')
	}

	static async MEDIADEL(id) { // 媒体审核 删除
		return await Http.request(serverUrl.MEDIADEL + `/${id}`, {}, 'DELETE', 'application/x-www-form-urlencoded')
	}
	
	static async MEDIAFINDMAL() { // 媒体审核新增媒体中的广告标签及广告
		return await Http.request(serverUrl.MEDIAFINDMAL, {}, 'GET')
	}
	
	static async MEDIAUPDATE(id, mediaStatus, mediaIntro='', mcToa='') { // 媒体审核 审核
		return await Http.request(serverUrl.MEDIAUPDATE + `/${id}`, {
			mediaStatus, 
			mediaIntro, 
			mcToa
		}, 'PUT', 'application/x-www-form-urlencoded')
	}
	
	static async MEDIAFINDALLADMIN(current, size, mediaName, mediaStatus) { // 媒体管理分页查询
		return await Http.request(serverUrl.MEDIAFINDALLADMIN, {
			current, 
			size, 
			mediaName, 
			mediaStatus
		}, 'GET')
	}
	
	static async MEPFINDALL(current, size, mediaName,channel) { // 分页查询媒体数据收益
		return await Http.request(serverUrl.MEPFINDALL, {
			current, 
			size,
			mediaName,
			channel
		}, 'GET')
	}
	
	static async PARTFINDALL(current, size, adName, channel) { // 分页查询广告位数据
		return await Http.request(serverUrl.PARTFINDALL, {
			current, 
			size,
			adName, 
			channel
		}, 'GET')
	}
	
	static async PLACEFINDALL(current, size, adName, status) { // 分页查询广告位数据
		return await Http.request(serverUrl.PLACEFINDALL, {
			current, 
			size,
			adName, 
			status
		}, 'GET')
	}
	
	static async PLACEFINDALLVERIFY(current, size, adName, status) { // 分页查询广告位数据
		return await Http.request(serverUrl.PLACEFINDALLVERIFY, {
			current, 
			size,
			adName, 
			status
		}, 'GET')
	}
	
	static async USERALLVERIFY(current, size, companyName, realName, userType) { // 分页查询用户审核
		return await Http.request(serverUrl.USERALLVERIFY, {
			current, 
			size,
			companyName, 
			realName, 
			userType
		}, 'GET')
	}
	
	static async CERTIFICATIONUPDATE(id, certificationStatus) { // 媒体审核 审核
		return await Http.request(serverUrl.CERTIFICATIONUPDATE + `/${id}`, {
			certificationStatus
		}, 'PUT', 'application/x-www-form-urlencoded')
	}
	
	static async WITHDRAWALFINDALL(current, size, orderNumber, amountStatus) { // 分页查询用户审核
		return await Http.request(serverUrl.WITHDRAWALFINDALL, {
			current, 
			size,
			orderNumber, 
			amountStatus
		}, 'GET')
	}
	
	static async WITHDRAWALUPDATE(id, amountStatus) { // 提现审核 审核
		return await Http.request(serverUrl.WITHDRAWALUPDATE + `/${id}`, {
			amountStatus
		}, 'PUT', 'application/x-www-form-urlencoded')
	}
	
	static async CONTRACTUPDATE(id, addressContract) { // 合同审核 审核
		return await Http.request(serverUrl.CONTRACTUPDATE + `/${id}`, {
			addressContract
		}, 'PUT', 'application/x-www-form-urlencoded')
	}
	
	static async INDEXALLDATA() { // 首页数据
		return await Http.request(serverUrl.INDEXALLDATA, {}, 'GET')
	}
	
	
	static async ACTIVEFINDALL(current, size) { // 活动配置 查询
		return await Http.request(serverUrl.ACTIVEFINDALL, {
			current, 
			size
		}, 'GET')
	}
	
	static async ACTIVEUPDATE(id, activeData) { // 活动配置 修改
		return await Http.request(serverUrl.ACTIVEUPDATE + `/${id}`, {
			activeData
		}, 'PUT', 'application/x-www-form-urlencoded')
	}
	
	static async ACTIVEDELETE(id) { // 活动配置 删除
		return await Http.request(serverUrl.ACTIVEDELETE + `/${id}`, {}, 'DELETE', 'application/x-www-form-urlencoded')
	}
	
	static async USERUPDATE(id, userStatus) { // 用户审核 审核
		return await Http.request(serverUrl.USERUPDATE + `/${id}`, {
			userStatus
		}, 'PUT', 'application/x-www-form-urlencoded')
	}
	
	static async PLACEFINDALLADMIN(current, size, adName, status) { // 广告位管理 查询
		return await Http.request(serverUrl.PLACEFINDALLADMIN, {
			current, 
			size,
			adName, 
			status
		}, 'GET')
	}
	
	static async SALESFIND(current, size) { // 广告主链接 查询
		return await Http.request(serverUrl.SALESFIND, {
			current, 
			size
		}, 'GET')
	}
	
	static async SALESFINDJUMPLOG(current, size, id) { // 曝光数据 查询
		return await Http.request(serverUrl.SALESFINDJUMPLOG, {
			current, 
			size,
			id
		}, 'GET')
	}
	
	static async SALESDELETE(id) { // 广告主链接 删除
		return await Http.request(serverUrl.SALESDELETE + `/${id}`, {}, 'DELETE', 'application/x-www-form-urlencoded')
	}
	
	static async SALESADD(advertingName, linkUrl) { // 新增广告主
		return await Http.request(serverUrl.SALESADD, {
			advertingName,
			linkUrl
		}, 'POST', 'application/x-www-form-urlencoded')
	}
	
	static async PLACEUPDATE(id, status, link='', pvPrice='', uvPrice='') { // 广告位审核 
		return await Http.request(serverUrl.PLACEUPDATE + `/${id}`, {
			link, 
			pvPrice, 
			uvPrice, 
			status
		}, 'PUT', 'application/x-www-form-urlencoded')
	}
	
	static async PLACEDEL(id) { // 广告位删除
		return await Http.request(serverUrl.PLACEDEL + `/${id}`, {}, 'DELETE', 'application/x-www-form-urlencoded')
	}
	
	static async ACTIVEADD(activityId, activityDescripte, activeData) { // 添加奖品配置
		return await Http.request(serverUrl.ACTIVEADD, {
			activityId, 
			activityDescripte, 
			activeData
		}, 'POST', 'application/json')
	}
	
	static async THIRDUPDATEVERITY(id, auditStatus) { // 投放审核 审核
		return await Http.request(serverUrl.THIRDUPDATEVERITY + `/${id}`, {
			id, 
			auditStatus
		}, 'PUT', 'application/x-www-form-urlencoded')
	}
	
	static async USERCOMMONUSER() { // 获取当前用户信息
		return await Http.request(serverUrl.USERCOMMONUSER, {}, 'GET')
	}
	
	static async MEPIMPORTMEP(excelFile, channel) { // 媒体上传
		return await Http.request(serverUrl.MEPIMPORTMEP + `/${id}`, {
			id, 
			auditStatus
		}, 'POST', 'application/x-www-form-urlencoded')
	}
}

export { 
	Request
}
